<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<title>APP不可操作服务通知</title>
		<link href="../../../css/mui.min.css" rel="stylesheet" />
		<link href="../../../css/global.css" rel="stylesheet" />
		<link href="../../../css/style.css" rel="stylesheet" />
		<link href="../../../css/task.css" rel="stylesheet" />
		<style>
			.mui-checkbox input[type=checkbox], .mui-radio input[type=radio]{
				top: 8px;
				right: -10px;
			}
			.item_box .item .text{
				overflow: hidden;
				margin: 5px auto;
				height: auto;
				line-height: initial;
			}
			.item_box .item .text span.cen{
				margin-left:0;
			}
			.item_box .item .text span{
				width: auto;
			}
			.mui-bar-nav{
				box-shadow: 0 1px 6px #ea1e1a;
			}
			.item_box .item .type{
				padding: 0 17px 10px;
			}
			.item_box .item .type p{
				overflow: hidden;
				text-align: right;
			}
			.item_box .item .type .lpl{
				width: 135px;
				float: left;
			}
			.d_int_tp{
				border: 0 !important;
				margin-top: 6px !important;
			}
			.select-tzstate{
				width: 100%;
				border: 0;
				color: #a9a9a9;
				font-size: 16px;
				text-align: left;
				padding: 15px;
			}
		</style>
	</head>
	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 id="title" class="mui-title">APP不可操作服务通知</h1>
		</header>
		<div class="mui-content">
			<div class="details_con select_con" id="search">
				<div class="clum">
					<input type="text" class="d_int_tp" id="customerName" placeholder="输入客户名称" />
				</div>
				<div class="clum">
					<input type="text" class="d_int_tp" id="serviceNo" placeholder="输入服务通知号" />
				</div>
				<div class="clum">
					<input type="text" class="d_int_tp" id="instrumentSerialNumber" placeholder="输入仪器序列号" />
				</div>
				<div class="clum">
					<input type="hidden" id="startTime" />
					<input type="text" class="d_int_tp" id="startTimeSel" readonly="readonly" placeholder="请选择开始时间" />
				</div>
				<div class="clum">
					<input type="hidden" id="endTime" />
					<input type="text" class="d_int_tp" id="endTimeSel" readonly="readonly" placeholder="请选择结束时间" />
				</div>
				<span style="margin: 0px 34px;color: #ddd;">注：最多查询一个月的数据</span>
				<div class="btm autoHeight">
					<p class="selectBtn" id="searchBtn" onclick="initData()">查 询</p>
				</div>
			</div>
			<!-- <div class="details_con shadow">
				<div class="clum">
					<span class="name">客户名称</span>
					<span class="txt">请输入客户名称</span>
				</div>
				<div class="clum">
					<span class="name">服务类型</span>
					<span class="txt">请输入服务类型</span>
				</div>
				<div class="clum">
					<span class="name">仪器序列号</span>
					<span class="txt">请输入仪器序列号</span>
				</div>

				<div class="clum">
					<span class="name">服务通知状态</span>
					<span class="txt">
						<button id='showUserPicker' class="mui-btn mui-btn-block" type='button'>请选择</button>
					</span>
				</div>
				<div class="btm autoHeight">
					<p class="selectBtn"><span>查询</span></p>
				</div>
			</div> -->
			<div class="details_con" style="margin: 30px 0 0 0;">
				<div class="item_box" id="itemBox"></div>
				<div style="height: 50px;"></div>
			</div>
		</div>
		<!-- 基础js start -->
		<script src="../../../js/mui.min.js"></script>
		<script src="../../../js/utils/h.js"></script>
		<script src="../../../js/constant.js"></script>
		<script src="../../../js/common.js"></script>
		<script src="../../../js/utils/base64.js"></script>
		<script src="../../../js/utils/md5.js"></script>
		<script src="../../../js/utils/sortMap.js"></script>
		<script src="../../../js/utils/http.js"></script>
		<script src="../../../js/utils/rolldate.min.js"></script>
		<script src="../../../js/app.js"></script>
		<script src="../../../js/mui.picker.js"></script>
		<script src="../../../js/mui.poppicker.js"></script>
		<!-- 基础js end -->
		<script type="text/javascript" charset="utf-8">
			
			var serviceNo,custName,startTime,endTime,instrumentSerialNumber
			(function($, doc) {
				$.init();
				$.plusReady(function() {
					var self = plus.webview.currentWebview();
					
					h('.mui-action-back').tap(function () {
						var noticeMenu=plus.webview.getWebviewById('view/service/notice/noticeMenu.html');
						if(noticeMenu){
							noticeMenu.evalJS('getNoticeCount()')
						}
					});
					// 开始时间
					new Rolldate({
						el: '#startTimeSel',
						format: 'YYYY-MM-DD hh:mm',
						beginYear: 2015,
						endYear: 2050,
						trigger: 'click',
						lang: {
							title: '请选择开始日期',
						},
						confirm: function(date) {
						}
					})
					
					// 结束日期
					new Rolldate({
						el: '#endTimeSel',
						format: 'YYYY-MM-DD hh:mm',
						beginYear: 2015,
						endYear: 2050,
						trigger: 'click',
						lang: {
							title: '请选择结束日期',
						},
						confirm: function(date) {
						}
					})
					
					var createTime = new Date().getTime()
					endTime = new Date(createTime).Format("yyyy-MM-dd HH:mm");
					startTime = new Date(createTime - 24*60*60*1000*7).Format("yyyy-MM-dd HH:mm");
					h('#endTimeSel').val(endTime)
					h('#startTimeSel').val(startTime)
					h('#endTime').val(endTime)
					h('#startTime').val(startTime)
					
					initData();
					
				});
			}(mui, document));
			
			
			function initData() {
				startTime = h("#startTimeSel").val();
				endTime = h("#endTimeSel").val();
				serviceNo = h('#serviceNo').val();
				custName = h('#customerName').val();
				instrumentSerialNumber = h('#instrumentSerialNumber').val();
				if(startTime&&!endTime){app.toast('请选择结束时间');return}
				if(!startTime&&endTime){app.toast('请选择开始时间');return}
				if(startTime&&endTime){
					var sd = startTime.replace(/-/g,'/').trim();
					var ed = endTime.replace(/-/g,'/').trim();
					if(new Date(ed).getTime() < new Date(sd).getTime()){
						app.toast("开始时间应小于结束时间");
						return false;
					}
					var one_month = getLast1Month(ed); //
					// 并计算一个月真实时间 与当前开始结束时间差对比
						one_month.last = one_month.last.replace(/-/g,'/').trim() + ' 00:00' 
						one_month.now = one_month.now.replace(/-/g,'/').trim() + ' 00:00' 
					    
					if(new Date(ed).getTime() - new Date(sd).getTime() > new Date(one_month.now).getTime() - new Date(one_month.last).getTime()){
						app.toast("开始结束时间不能超过一个月");
						return false;
					}
				}
				app.showWaiting('加载中...')
				 ajaxGet(BASE_URL + "cc/notice/getCCServiceNoticeList", {
					"enginnerId": app.getUser().enginnerId,
					"serviceNo":serviceNo,
					"custName":custName,
					"startTime":startTime,
					"endTime":endTime,
					"instrumentSerialNumber":instrumentSerialNumber
				}, function(data) {
					app.closeWaiting()
					if (data.code === 200) {
						var str = '';
						if (data.data && data.data.length > 0) {
							for (var c = 0; c < data.data.length; c++) {
								//默认0待接受，1已接受，2已签到，3已签离，4已完成,5自动签离，6已拒绝
								var xianshi = '';
								var enginnerType = data.data[c].enginnerType ? data.data[c].enginnerType : "";
								var isVip = data.data[c].isVip ? data.data[c].isVip : "";
								var userIsdpel = data.data[c].userIsdpel ? data.data[c].userIsdpel : "";
								if(userIsdpel=='1'){
									xianshi = 'DPEL/'
								}
								if(isVip!=''){
									xianshi += isVip
								}else{
									if(enginnerType!=''){
										xianshi += enginnerType
									}
								}
								planState = data.data[c].planState;
								str += '<div class="item" onclick="jumpPage(\'' + planState + '\',\'' + data.data[c].id + '\',\'' +
									data.data[c].serviceNo + '\',\'' + data.data[c].planId + '\')">';
								str += '<div class="bar">';
								str += '<span class="number"><img src="../../../images/icon_204.png" />' + data.data[c].serviceNo + '</span>';
								str += '<span class="vip">'+enginnerType+'</span>';
								str += '</div>';
								str += '<div class="text">';
								str += '<span class="cen" style="color: #333;">' + data.data[c].customerName + '</span>';
								str += '</div>';
								str += '<div class="type">';
								var createTime = data.data[c].createTime ? data.data[c].createTime : "";
								var subServiceType = data.data[c].subServiceType ? data.data[c].subServiceType : "";
								var isWarranty = data.data[c].isWarranty ? data.data[c].isWarranty : "";
								var serviceStatus = data.data[c].serviceStatus ? data.data[c].serviceStatus : "";
								var appRemark = data.data[c].appRemark ? data.data[c].appRemark : "";
								str += '<p><img src="../../../images/icon_202.png"/><span class="lpl">提交时间：</span>' + createTime + '</p>'
								str += '<p><img src="../../../images/icon_203.png"/><span class="lpl">服务子类型：</span>' + subServiceType + '</p>'
								str += '<p><img src="../../../images/icon_222.png"/><span class="lpl">保修性质：</span>' + isWarranty + '</p>'
								str += '<p><img src="../../../images/icon_205.png"/><span class="lpl">CC服务通知状态：</span>' + serviceStatus +'</p>'
								str += '<p style="color: #ea1e1a"><img src="../../../images/icon_218.png"/><span class="lpl" style="color: #ea1e1a">APP不可操作原因：</span>' + appRemark +'</p>'
								// if (planState == '0') {
								// 	planStateName = "待接受";
								// } else if (planState == '1') {
								// 	planStateName = "已接受";
								// } else if (planState == '2') {
								// 	planStateName = "已签到";
								// } else if (planState == '3') {
								// 	planStateName = "已签离";
								// } else if (planState == '4') {
								// 	planStateName = "已完成";
								// } else if (planState == '5') {
								// 	planStateName = "自动签离";
								// } else if (planState == '6') {
								// 	planStateName = "已拒绝";
								// }
								// str += '<p><div class="lpl">状态：</div><span>' + planStateName +
								// 	'</span><img src="../../../images/icon_205.png"/></p>';
								str += '</div>';
								str += '</div>';
							}
							h('#itemBox').html(str);
						} else {
							var html = '<div class="nodata">—— 暂无数据 ——</div>';
							h("#itemBox").html(html);
						}
					} else {
						var html = '<div class="nodata">—— 暂无数据 ——</div>';
						h("#itemBox").html(html);
						app.toast(data.msg)
					}
				}, function(errorMsg) {
					app.closeWaiting()
					var html = '<div class="nodata">—— 暂无数据 ——</div>';
					h("#itemBox").html(html);
					app.toast("数据获取失败，请检查网络连接");
				});
			}
		</script>
	</body>
</html>